﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;

namespace CSharpNewFeaturesUse
{
    public class ListPatternMatch
    {
        public static void ShowUse()
        {
            int[] grades = { 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, };
            Console.WriteLine(TestMatch(grades.ToList()));
            Console.WriteLine(TestMatch(grades[1..]));
        }
        private static string TestMatch(IEnumerable<int> grades)
        {
            // 列表模式匹配可以单独针对列表中每一个项进行匹配
            return grades.ToList() switch
            {
            [100, ..] => "A",
            [>= 90, ..] => "B",
                _ => "C"
            };

        }
    }
}